import server from "../util/request.js";

// 获取所有供应商
export function getAllSuppliers() {
    return server({
        url: "/api/suppliers/findAll",
        method: "GET"
    });
}

// 根据ID获取供应商
export function getSupplierById(supplierId) {
    return server({
        url: `/api/suppliers/findById/${supplierId}`,
        method: "GET"
    });
}

// 添加供应商
export function addSupplier(supplierData) {
    return server({
        url: "/api/suppliers/add",
        method: "POST",
        data: supplierData
    });
}

// 修改供应商
export function updateSupplier(supplierData) {
    return server({
        url: "/api/suppliers/update",
        method: "PUT",
        data: supplierData
    });
}

// 冻结/解冻供应商
export function freezeSupplier(supplierId, status) {
    return server({
        url: `/api/suppliers/freeze/${supplierId}`,
        method: "PUT",
        params: { status }
    });
}

// 删除供应商
export function deleteSupplier(supplierId) {
    return server({
        url: `/api/suppliers/delete/${supplierId}`,
        method: "DELETE"
    });
}

// 搜索供应商
export function searchSuppliers(keyword) {
    return server({
        url: "/api/suppliers/search",
        method: "GET",
        params: { keyword }
    });
}
